# 精简版
FROM golang:1.21-alpine3.18  AS builder

COPY . /src
WORKDIR /src

RUN sed -i 's#https://dl-cdn.alpinelinux.org/alpine/v3.18#https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.18#g' /etc/apk/repositories \
    && apk add make \
    && export GOPROXY=https://goproxy.cn,direct \
    && export GO111MODULE=on \
    && make build \
    && apk add tzdata &&  cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&     echo "Asia/Shanghai" > /etc/timezone

FROM debian:stable-slim

# 安装所需的软件包和时区数据
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata && \
    rm -rf /var/lib/apt/lists/* && apt-get autoremove -y && apt-get autoclean -y && ln -s /lib /lib64

# 设置时区
ENV TZ=Asia/Shanghai

COPY --from=builder /src/bin /app

WORKDIR /app

VOLUME /data/conf

CMD ["./server", "-conf", "/data/conf"]
